const Router = require('koa-router')
const router = new Router()
const axios = require('axios');

router.post('/deepseek/chat', async (ctx) => {
    console.log(ctx.request.body)
    const message = ctx.request.body.content // 前端传过来的消息
    const data = {
        model: 'deepseek-r1:1.5b', // 模型名称
        messages: [
            {
                role: 'user', // 角色
                content: message
            }
        ],
        stream: false // 是否流式返回
    }
    // 跟 deepseek 模型进行通信

    await axios.post("http://localhost:11434/api/chat", data).then(response => {
        console.log(response.data.message.content);
        ctx.body = {
            code: 200,
            content: response.data.message.content
        }
    })


})

module.exports = {
    teachTextRouter: router
}